package com.tzxx.spider.service;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.tzxx.spider.dao.ArticleMapper;
import com.tzxx.spider.domain.Article;
import com.tzxx.spider.vo.PageVo;
import com.github.pagehelper.PageHelper;

/**
 * @author Created by tzxx
 * @since : 2019/7/19.
 */
@Service
@Transactional
public class ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    public void insert(Article article){
        articleMapper.insert(article);
    }

    public List<Article> getAllArticle(PageVo pageVo) {
        PageHelper.startPage(pageVo.getPageNumber(), pageVo.getPageSize());
        return articleMapper.search(pageVo);
    }

    public Article getArticleById(long id){
        return articleMapper.selectById(id);
    }

}
